import 'dart:ui';

import 'package:flutter/material.dart';
import 'show_pic_widget.dart';

//展示毛玻璃相关
class ShowDimGlassWidget extends StatelessWidget {
  final double width;
  final double height;
  final String url;
  Color? shadeColor;

  ShowDimGlassWidget(
    this.url, {
    required this.width,
    required this.height,
    this.shadeColor,
  });

  @override
  Widget build(BuildContext context) {
    if(shadeColor == null){
      shadeColor = Colors.grey.shade400;
    }
    return Container(
      width: width,
      height: height,
      padding: EdgeInsets.zero,
      child: Stack(
        children: [
          ConstrainedBox(
            constraints: BoxConstraints.expand(),
            child: ShowPicWidget(
              url,
              radius: 0,
              height: height,
            ),
          ),
          Center(
            child: ClipRRect(
              child: BackdropFilter(
                child: Opacity(
                  opacity: 0.5,
                  child: Container(
                    decoration: BoxDecoration(color: shadeColor),
                    height: height,
                    width: double.infinity,
                  ),
                ),
                filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
              ),
            ),
          ),
        ],
      ),
    );
    ;
  }
}
